<?php

namespace framework\system\kernel;

class Controller extends CModel {

    public $defaultAction = "Index";
    public $actionId = "Index";
    protected $view;

    public function __construct() {
        $this->view = new View();
    }

    public function beforAction() {
        
    }

    public function afterAction() {
        
    }

    public function actionError() {
        
    }

    final public function action($args = NULL) {
        $this->beforAction($args);
        $action_id = "action" . ucwords($this->actionId);
        if ($action_id == "action") {
            $action_id = "action" . $this->defaultAction;
        }
        $this->$action_id($args);
        $this->afterAction($args);
    }

}
